/*
 * Created on Mar 23, 2006
 *
 */
package org.mushroomdb.triggers;

import org.mushroomdb.catalog.Table;
import org.mushroomdb.engine.EvaluationEngine;
import org.mushroomdb.query.Query;
import org.mushroomdb.service.ServiceManager;

/**
 * DROP TRIGGER <trigger name>
 * 
 * @author mchiodi
 */
public class DropTriggerQuery extends Query {
	private String name;

	/**
	 * 
	 */
	public DropTriggerQuery(String name) {
		super();
		this.name = name;
	}

	/**
	 * @see org.mushroomdb.query.Query#execute(org.mushroomdb.engine.EvaluationEngine)
	 */
	public Object execute(EvaluationEngine evaluationEngine) {
		TriggersService triggersService = (TriggersService) ServiceManager.getInstance().getService(TriggersService.class);
		Trigger trigger = triggersService.getTrigger(this.name);
		Table table = triggersService.getTable(trigger);
		return new Boolean(triggersService.removeTrigger(trigger,table));
	}

}
